package com.rd.student.jiaji.class2.shirui.exam0808.prac1;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Student {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        try {

            FileWriter writer = new FileWriter("Student.txt");
            writer.write("姓名 "+"语文成绩 "+"数学成绩 "+"总分 " +"\n");
            for (int i = 1; i <= 3; i++) {
                System.out.println("请输入第" + i + "个学生的信息：");

                System.out.print("姓名：");
                String name = scanner.nextLine();

                System.out.print("语文成绩：");
                int chineseScore = Integer.parseInt(scanner.nextLine());

                System.out.print("数学成绩：");
                int mathScore = Integer.parseInt(scanner.nextLine());

                int allScore = chineseScore + mathScore;

                writer.write(name + " " + chineseScore + " " + mathScore + " " + allScore + "\n");

                System.out.println("录入成功！");
                System.out.println();
            }

            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
